package com.pro.controller;

import com.pro.entity.Car.Car;
import com.pro.entity.Student.Student;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * Description: 学生访问层  供vue-cli学习提供数据
 * <p>
 * Author: wilson
 * <p>
 * Date: 2024/1/24 21:53
 */
@Slf4j
@CrossOrigin
@RestController
public class StudentController {

    @GetMapping("/getStudents")
    public List<Student> getStudents() {
        List<Student> students = new ArrayList<>();


        students.add(Student.builder().id(1L).name("张三").age(18).build());
        students.add(Student.builder().id(2L).name("李四").age(19).build());
        students.add(Student.builder().id(3L).name("王五").age(28).build());

        log.info("获取学生信息。。。");
        return students;
    }

    @GetMapping("/getCars")
    public List<Car> getCars() {
        List<Car> cars = new ArrayList<>();

        cars.add(Car.builder().id(1L).name("张三").price(188d).build());
        cars.add(Car.builder().id(2L).name("李四").price(199d).build());
        cars.add(Car.builder().id(3L).name("王五").price(288d).build());

        log.info("获取汽车信息。。。");
        return cars;
    }
}
